home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 03 - 1987 / 03.01 Jan 87 / pascal source / myWriteStuff < prev    next >
Encoding:
Text File  |  1986-11-21  |  20.3 KB  |  835 lines  |  [TEXT/PJMM]

  1. UNIT myWriteStuff;
  2.  
  3. INTERFACE
  4.  
  5.     USES
  6.         ROM85, EditorGlobals, ScrollStuff;
  7.  
  8.     PROCEDURE UpdateMenus;
  9.     PROCEDURE UpdateFonts;
  10.     PROCEDURE UpdateSize;
  11.     PROCEDURE UpdateStyle;
  12.     PROCEDURE UpdateJust;
  13.     PROCEDURE UpdateMode;
  14.     PROCEDURE ShowFonts (FontNum : integer);
  15.     PROCEDURE doCloseWindow (goodbyWindow : windowPtr);
  16.     PROCEDURE doAbout;
  17.     PROCEDURE doNewWindow;
  18.     PROCEDURE doMenubar (menuResult : LongInt);
  19.     PROCEDURE doContent (ConEvent : EventRecord;
  20.                                     contentWindow : windowPtr);
  21.     PROCEDURE doDrag (GrabWindow : WindowPtr;
  22.                                     GlobalMouse : point);
  23.     PROCEDURE doGrow (ResizeWindow : WindowPtr;
  24.                                     Globalmouse : point;
  25.                                     Zoomflg : Boolean);
  26.  
  27. IMPLEMENTATION
  28.  
  29.     PROCEDURE BashText;
  30.         VAR
  31.             FontIRec : FontInfo;
  32.             Height : integer; {calculated new lineheight}
  33.             CharPos : integer;
  34.             ControlLine : integer;
  35.     BEGIN
  36.         SetPort(myWindows[currentWindow]);
  37.         GetFontInfo(FontIRec); {from current grafport}
  38.         myText[currentWindow]^^.txFont := thePort^.txFont;
  39.         myText[currentWindow]^^.txFace := thePort^.txFace;
  40.         myText[currentWindow]^^.txMode := thePort^.txMode;
  41.         myText[currentWindow]^^.txSize := thePort^.txSize;
  42.         myText[currentWindow]^^.fontAscent := FontIRec.ascent;
  43.         Height := FontIRec.ascent + FontIRec.descent + FontIRec.leading;
  44.         myText[currentWindow]^^.lineHeight := Height;
  45.         myText[currentWindow]^^.just := LastJust;
  46.  
  47.         ControlLine := GetCtlValue(myHControls[currentWindow]);
  48.         CharPos := myText[currentWindow]^^.lineStarts[ControlLine];
  49.         TECalText(myText[currentWindow]);
  50.         InvalRect(myText[currentWindow]^^.ViewRect);
  51.         AdjustScrollBar(currentWindow);
  52.         ScrollChar(currentWindow, CharPos, False); {reset scroller value}
  53.         CheckInsertion(currentWindow);
  54.  
  55.     END;
  56.  
  57.     PROCEDURE doFonts (fontNo : integer);
  58.         VAR
  59.             FontNumber : integer;
  60.             FontName : Str255;
  61.     BEGIN
  62.         IF currentWindow <> 0 THEN
  63.             BEGIN
  64.                 getItem(myMenus[FontMenu], fontNo, FontName);
  65.                 GetFNum(FontName, FontNumber);
  66.                 SetPort(myWindows[currentWindow]);
  67.                 TextFont(FontNumber); {change port's font}
  68.                 UpdateFonts;    {update menu}
  69.                 BashText;    {update window}
  70.             END;
  71.     END;
  72.  
  73.     PROCEDURE doSize (sizeNo : integer);
  74.         CONST
  75.             DialogID = 129; {other dialog}
  76.         VAR
  77.             sizeNumber : LongInt;
  78.             sizeNum : integer;
  79.             sizeName : Str255;
  80.             SizeCount : integer;
  81.             dialogP : DialogPtr;
  82.             item : integer;
  83.             dtype : integer;
  84.             ditem : handle;
  85.             drect : rect;
  86.             dtext : Str255;
  87.             activeSize : integer;
  88.             LongSize : LongInt;
  89.             sizeStr : Str255;
  90.     BEGIN
  91.         IF currentWindow <> 0 THEN
  92.             BEGIN
  93.                 SizeCount := (CountMItems(myMenus[SizeMenu])) - 2;
  94.                 IF (sizeNo <= SizeCount) AND (sizeNo > 0) THEN
  95.                     BEGIN
  96.                         GetItem(myMenus[SizeMenu], sizeNo, sizeName);
  97.                         StringToNum(sizeName, sizeNumber);
  98.                         sizeNum := LoWord(sizeNumber);
  99.                         SetPort(myWindows[currentWindow]);
  100.                         TextSize(sizeNum); {change port's text size}
  101.                         UpdateSize;
  102.                         BashText;
  103.                     END; {of sizeno}
  104.  
  105.                 IF sizeNo = SizeCount + 2 THEN
  106.                     BEGIN    {do other}
  107.                         activeSize := thePort^.txSize;
  108.                         LongSize := LongInt(activeSize);
  109.                         NumToString(LongSize, sizeStr);
  110.                         ParamText(sizeStr, '', '', '');
  111.                         dialogP := GetNewDialog(DialogID, NIL, pointer(-1));
  112.                         ModalDialog(NIL, item);
  113.                         GetDItem(dialogP, otherItem, dtype, ditem, drect);
  114.                         GetIText(ditem, dtext);
  115.                         StringToNum(dtext, LongSize);
  116.                         sizeNum := LoWord(LongSize);
  117.                         DisposDialog(dialogP);
  118.  
  119.                         IF (sizeNum > 0) AND (sizeNum < sizelimit) THEN
  120.                             BEGIN
  121.                                 SetPort(myWindows[currentWindow]);
  122.                                 TextSize(sizeNum); {change port's text size}
  123.                                 UpdateSize;
  124.                                 BashText;
  125.                             END
  126.                         ELSE
  127.                             sysbeep(5); {size too big}
  128.                     END; {of other}
  129.             END; {of currentWindow<>0}
  130.     END;    {of proc}
  131.  
  132.     PROCEDURE doStyle (StyleNo : integer);
  133.         VAR
  134.             NewStyle : Style;
  135.  
  136.     BEGIN
  137.         IF currentWindow <> 0 THEN
  138.             BEGIN
  139.                 IF myWindows[currentWindow] = FrontWindow THEN
  140.                     BEGIN
  141.                         SetPort(myWindows[currentWindow]);
  142.                         NewStyle := [];
  143.                         CASE StyleNo OF
  144.                             sLeft : 
  145.                                 myText[currentWindow]^^.just := teJustLeft;
  146.                             sCenter : 
  147.                                 myText[currentWindow]^^.just := teJustCenter;
  148.                             sRight : 
  149.                                 myText[currentWindow]^^.just := teJustRight;
  150.                             sPlain : 
  151.                                 BEGIN
  152.                                     textface([]);
  153.                                 END;
  154.                             sBold : 
  155.                                 BEGIN
  156.                                     NewStyle := [bold];
  157.                                 END;
  158.                             sItalic : 
  159.                                 BEGIN
  160.                                     NewStyle := [italic];
  161.                                 END;
  162.                             sUnderline : 
  163.                                 BEGIN
  164.                                     NewStyle := [underline];
  165.                                 END;
  166.                             sOutline : 
  167.                                 BEGIN
  168.                                     NewStyle := [outline];
  169.                                 END;
  170.                             sShadow : 
  171.                                 BEGIN
  172.                                     NewStyle := [shadow];
  173.                                 END;
  174.                             sCondense : 
  175.                                 BEGIN
  176.                                     NewStyle := [condense];
  177.                                 END;
  178.                             sExtend : 
  179.                                 BEGIN
  180.                                     NewStyle := [extend];
  181.                                 END;
  182.                             OTHERWISE
  183.                                 BEGIN
  184.                                 END;
  185.                         END;  {of case}
  186.                         IF NewStyle <= thePort^.txFace THEN
  187.                             textface(thePort^.txFace - NewStyle)
  188.                         ELSE
  189.                             textface(thePort^.txFace + NewStyle);
  190.                         UpdateJust;
  191.                         UpdateStyle;
  192.                         BashText;
  193.                     END; {of currentWindow}
  194.             END; {of frontwindow}
  195.     END; {of proc}
  196.  
  197.     PROCEDURE doMode (ModeNo : integer);
  198.     BEGIN
  199.         IF currentWindow <> 0 THEN
  200.             BEGIN
  201.                 SetPort(myWindows[currentWindow]);
  202.                 TextMode(ModeNo);
  203.                 UpdateMode;
  204.                 BashText;
  205.             END;
  206.     END;
  207.  
  208.     PROCEDURE UpdateMenus;
  209.     BEGIN
  210.         UpdateFonts;
  211.         UpdateSize;
  212.         UpdateStyle;
  213.         UPdateJust;
  214.         UpdateMode;
  215.     END;
  216.  
  217.     PROCEDURE UpdateFonts;
  218.         VAR
  219.             i : integer;
  220.             FontCount : integer;
  221.             FontNumber : integer;
  222.             activeFont : Str255;
  223.             FontName : Str255;
  224.     BEGIN
  225.         GetFontName(thePort^.txFont, activeFont);
  226.         FontCount := CountMItems(myMenus[FontMenu]);
  227.         FOR i := 1 TO FontCount DO
  228.             BEGIN
  229.                 GetItem(myMenus[FontMenu], i, FontName);
  230.                 IF (FontName = activeFont) THEN
  231.                     BEGIN
  232.                         CheckItem(myMenus[FontMenu], LastmFont, false);
  233.                         CheckItem(myMenus[FontMenu], i, true);
  234.                         LastmFont := i;
  235.                         GetFNum(FontName, FontNumber);
  236.                         LastFont := FontNumber;
  237.                         ShowFonts(LastFont);
  238.                     END;    {of if then}
  239.             END;    {of i loop}
  240.     END;
  241.  
  242.     PROCEDURE UpdateSize;
  243.         VAR
  244.             sizeCount : integer;
  245.             sizeNumber : LongInt;
  246.             sizeNum : integer;
  247.             activeSize : integer;
  248.             sizeName : Str255;
  249.             i : integer;
  250.             doneflg : boolean;
  251.     BEGIN
  252.         doneflg := false;
  253.         activeSize := thePort^.txSize;
  254.         SizeCount := (CountMItems(myMenus[SizeMenu])) - 2;
  255.         FOR i := 1 TO SizeCount DO
  256.             BEGIN
  257.                 GetItem(myMenus[SizeMenu], i, sizeName);
  258.                 StringToNum(sizeName, sizeNumber);
  259.                 sizeNum := LoWord(sizeNumber);
  260.                 IF (sizeNum = activeSize) THEN
  261.                     BEGIN
  262.                         CheckItem(myMenus[SizeMenu], LastmSize, false);
  263.                         CheckItem(myMenus[SizeMenu], i, true);
  264.                         LastmSize := i;
  265.                         LastSize := sizeNum;
  266.                         doneflg := true;
  267.                     END;{of if then}
  268.             END;    {of i loop}
  269.  
  270.         IF doneflg = false THEN
  271.             BEGIN    {do other}
  272.                 IF (activeSize > 0) AND (activeSize < sizelimit) THEN
  273.                     BEGIN
  274.                         CheckItem(myMenus[SizeMenu], LastmSize, false);
  275.                         CheckItem(myMenus[SizeMenu], SizeCount + 2, true);
  276.                         LastmSize := SizeCount + 2;
  277.                         LastSize := activeSize;
  278.                     END;
  279.             END;
  280.     END; {of proc}
  281.  
  282.     PROCEDURE UpdateStyle;
  283.         VAR
  284.             i, j : integer;
  285.             StyleCount : integer;
  286.             activeStyle : Style;
  287.             MenuStyle : Style;
  288.     BEGIN
  289.         StyleCount := (CountMItems(myMenus[StyleMenu]) - Style2Items);
  290.         activeStyle := thePort^.txFace;
  291.         FOR i := 1 TO StyleCount DO
  292.             BEGIN
  293.                 CASE i OF
  294.                     1 : 
  295.                         MenuStyle := [];
  296.                     2 : 
  297.                         MenuStyle := [bold];
  298.                     3 : 
  299.                         MenuStyle := [italic];
  300.                     4 : 
  301.                         MenuStyle := [underline];
  302.                     5 : 
  303.                         MenuStyle := [outline];
  304.                     6 : 
  305.                         MenuStyle := [shadow];
  306.                     7 : 
  307.                         MenuStyle := [condense];
  308.                     8 : 
  309.                         MenuStyle := [extend];
  310.                     OTHERWISE
  311.                         MenuStyle := [];
  312.                 END;  {of case i}
  313.  
  314.                 IF ((MenuStyle <= activeStyle) AND (MenuStyle <> [])) THEN
  315.                     BEGIN
  316.                         CheckItem(myMenus[StyleMenu], i, true);
  317.                         CheckItem(myMenus[StyleMenu], 1, false);
  318.                         LastmStyle := i;
  319.                         LastStyle := activeStyle;
  320.                     END
  321.                 ELSE IF activeStyle = [] THEN
  322.                     BEGIN
  323.                         CheckItem(myMenus[StyleMenu], 1, true);
  324.                         FOR j := 2 TO StyleCount DO
  325.                             BEGIN
  326.                                 CheckItem(myMenus[StyleMenu], j, false);
  327.                             END; {of j loop}
  328.                         LastmStyle := 1;
  329.                         LastStyle := activeStyle;
  330.                     END { of []}
  331.                 ELSE
  332.                     BEGIN
  333.                         CheckItem(myMenus[StyleMenu], i, false);
  334.                     END;
  335.             END;    {of i loop}
  336.     END;
  337.  
  338.     PROCEDURE UpdateJust;
  339.         VAR
  340.             i : integer;
  341.             activeJust : integer;
  342.     BEGIN
  343.         IF currentWindow <> 0 THEN
  344.             BEGIN
  345.                 IF myWindows[currentWindow] = FrontWindow THEN
  346.                     BEGIN
  347.                         i := (CountMItems(myMenus[StyleMenu]) - Style2Items);
  348.                         CASE LastJust OF
  349.                             teJustLeft : 
  350.                                 CheckItem(myMenus[StyleMenu], i + 2, false);
  351.                             teJustCenter : 
  352.                                 CheckItem(myMenus[StyleMenu], i + 3, false);
  353.                             teJustRight : 
  354.                                 CheckItem(myMenus[StyleMenu], i + 4, false);
  355.                             OTHERWISE
  356.                                 BEGIN
  357.                                 END;
  358.                         END;  {of case}
  359.  
  360.                         activeJust := myText[currentWindow]^^.just;
  361.                         LastJust := activeJust;
  362.                         CASE activeJust OF
  363.                             teJustLeft : 
  364.                                 BEGIN
  365.                                     CheckItem(myMenus[StyleMenu], i + 2, true);
  366.                                     LastmJust := i + 2;
  367.                                 END;
  368.                             teJustCenter : 
  369.                                 BEGIN
  370.                                     CheckItem(myMenus[StyleMenu], i + 3, true);
  371.                                     LastmJust := i + 3;
  372.                                 END;
  373.                             teJustRight : 
  374.                                 BEGIN
  375.                                     CheckItem(myMenus[StyleMenu], i + 4, true);
  376.                                     LastmJust := 1 + 4;
  377.                                 END;
  378.                             OTHERWISE
  379.                                 BEGIN
  380.                                 END;
  381.                         END; {of case}
  382.                     END;
  383.             END;
  384.     END;
  385.  
  386.     PROCEDURE UpdateMode;
  387.         VAR
  388.             activeMode : integer;
  389.     BEGIN
  390.         activeMode := thePort^.txMode;
  391.         CheckItem(myMenus[ModeMenu], LastmMode, false);
  392.         CASE activeMode OF
  393.             1 : 
  394.                 BEGIN
  395.                     CheckItem(myMenus[ModeMenu], 1, true);
  396.                     LastmMode := 1;
  397.                 END;
  398.             2 : 
  399.                 BEGIN
  400.                     CheckItem(myMenus[ModeMenu], 2, true);
  401.                     LastmMode := 2;
  402.                 END;
  403.             3 : 
  404.                 BEGIN
  405.                     CheckItem(myMenus[ModeMenu], 3, true);
  406.                     LastmMode := 3;
  407.                 END;
  408.             OTHERWISE
  409.                 BEGIN
  410.                 END;
  411.         END; { of case}
  412.         LastMode := activeMode;
  413.     END;
  414.  
  415.     PROCEDURE ShowFonts; {(FontNum : integer);}
  416.         VAR
  417.             i : integer;
  418.             sizeStr : Str255;
  419.             sizeNum : LongInt;
  420.     BEGIN
  421.         FOR i := 1 TO (CountMItems(myMenus[sizeMenu]) - 2) DO
  422.             BEGIN
  423.                 GetItem(myMenus[sizeMenu], i, sizeStr);
  424.                 StringToNum(sizeStr, sizeNum);
  425.                 IF RealFont(FontNum, sizeNum) THEN
  426.                     SetItemStyle(myMenus[sizeMenu], i, [Outline])
  427.                 ELSE
  428.                     SetItemStyle(myMenus[sizeMenu], i, []);
  429.             END;    {of i}
  430.     END;    {of proc}
  431.  
  432.     PROCEDURE doCloseWindow; {(goodbyWindow : windowPtr}
  433.         VAR
  434.             i : integer;
  435.     BEGIN
  436.         HideWindow(goodbyWindow);
  437.         CurrentWindow := 0;
  438.         FOR i := 1 TO MaxWindows DO
  439.             BEGIN
  440.                 IF goodbyWindow = myWindows[i] THEN
  441.                     BEGIN
  442.                         goodbyList[i] := i;
  443.                     END;
  444.             END;
  445.     END;
  446.  
  447.     PROCEDURE doAbout;
  448.         CONST
  449.             DialogID = 128;
  450.         VAR
  451.             dialogP : DialogPtr;
  452.             item : integer;
  453.     BEGIN
  454.         dialogP := GetNewDialog(DialogID, NIL, pointer(-1));
  455.         ModalDialog(NIL, item);
  456.         DisposDialog(dialogP);
  457.     END;
  458.  
  459.     PROCEDURE doNewWindow;
  460.         VAR
  461.             i : integer;
  462.             doneflg : boolean;
  463.     BEGIN
  464.         doneflg := false;
  465.         FOR i := 1 TO MaxWindows DO
  466.             BEGIN
  467.                 IF doneflg = false THEN
  468.                     BEGIN
  469.                         IF goodbyList[i] = i THEN
  470.                             BEGIN    {window is free}
  471.                                 CurrentWindow := i;
  472.                                 SetPort(myWindows[CurrentWindow]);
  473.                                 UpdateMenus;
  474.                                 goodbyList[i] := 0;
  475.                                 doneflg := true;
  476.  
  477.                                 TESetSelect(0, MaxLines, myText[i]);
  478.                                 TEDelete(myText[i]);
  479.                                 ShowWindow(myWindows[i]);
  480.                                 SelectWindow(myWindows[i]);
  481.                                 AdjustScrollBar(i);
  482.                                 CheckInsertion(i);
  483.                             END;    {of free window stuff}
  484.                     END;     {of if doneflg}
  485.             END;    {of for i loop}
  486.         IF doneflg = false THEN
  487.             sysBeep(5);    {no windows left}
  488.     END;    {of proc}
  489.  
  490.     PROCEDURE doMenubar; {(menuResult : LongInt)}
  491.         VAR
  492.             theMenu : integer;
  493.             theItem : integer;
  494.             daName : STR255;
  495.             accItem : integer;
  496.             i : integer;
  497.     BEGIN
  498.         theMenu := HiWord(menuResult); {menu}
  499.         theItem := LoWord(menuResult); {item}
  500.         CASE theMenu OF
  501.             AppleMenu : 
  502.                 BEGIN
  503.                     IF theItem = aAbout THEN
  504.                         doAbout
  505.                     ELSE
  506.                         BEGIN
  507.                             GetItem(myMenus[AppleMenu], theItem, daName);
  508.                             accItem := OpenDeskAcc(daName);
  509.                         END; {else}
  510.                 END; {of AppleMenu}
  511.             FileMenu : 
  512.                 BEGIN
  513.                     CASE theItem OF
  514.                         fNew : 
  515.                             BEGIN
  516.                                 doNewWindow;
  517.                             END;
  518.                         fOpen : 
  519.                             BEGIN
  520.                             END;
  521.                         fClose : 
  522.                             BEGIN
  523.                                 IF currentWindow <> 0 THEN
  524.                                     IF myWindows[currentWindow] = FrontWindow THEN
  525.                                         doCloseWindow(myWindows[currentWindow]);
  526.                             END;
  527.                         fSave : 
  528.                             BEGIN
  529.                             END;
  530.                         fSaveAs : 
  531.                             BEGIN
  532.                             END;
  533.                         fPageSet : 
  534.                             BEGIN
  535.                             END;
  536.                         fPrint : 
  537.                             BEGIN
  538.                             END;
  539.                         fQuit : 
  540.                             BEGIN
  541.                                 FOR i := 1 TO MaxWindows DO
  542.                                     BEGIN
  543.                                         DisposeControl(myVControls[i]);
  544.                                         DisposeControl(myHControls[i]);
  545.                                         TEDispose(myText[i]);
  546.                                         DisposeWindow(myWindows[i]);
  547.                                     END;
  548.                                 Finished := true;
  549.                             END;
  550.                         OTHERWISE
  551.                             BEGIN
  552.                             END;
  553.                     END; {of theitem}
  554.                 END; {of FileMenu}
  555.             EditMenu : 
  556.                 BEGIN
  557.                     IF NOT SystemEdit(theitem - 1) THEN
  558.                         BEGIN
  559.                             CASE theItem OF
  560.                                 eUndo : 
  561.                                     BEGIN
  562.                                         sysbeep(5);
  563.                                     END;
  564.                                 eCut : 
  565.                                     BEGIN
  566.                                         IF currentWindow <> 0 THEN
  567.                                             BEGIN
  568.                                                 CheckInsertion(currentWindow);
  569.                                                 TECut(myText[currentWindow]);
  570.                                                 AdjustScrollBar(currentWindow);
  571.                                                 CheckInsertion(currentWindow);
  572.                                                 dummy := ZeroScrap;
  573.                                                 dummy := TEToScrap;
  574.                                             END
  575.                                         ELSE
  576.                                             sysbeep(5);
  577.                                     END;
  578.                                 eCopy : 
  579.                                     BEGIN
  580.                                         IF currentWindow <> 0 THEN
  581.                                             BEGIN
  582.                                                 CheckInsertion(currentWindow);
  583.                                                 TECopy(myText[currentWindow]);
  584.                                                 dummy := ZeroScrap;
  585.                                                 dummy := TEToScrap;
  586.                                             END
  587.                                         ELSE
  588.                                             sysbeep(5);
  589.                                     END;
  590.                                 ePaste : 
  591.                                     BEGIN
  592.                                         IF currentWindow <> 0 THEN
  593.                                             BEGIN
  594.                                                 IF TEFromScrap <> noErr THEN
  595.                                                     BEGIN    {Desk Scrap to TEScrap}
  596.                                                     END;
  597.                                                 IF (myText[currentWindow]^^.teLength + TEGetScrapLen) > MaxInt THEN
  598.                                                     SysBeep(5)
  599.                                                 ELSE
  600.                                                     BEGIN
  601.                                                         CheckInsertion(currentWindow);
  602.                                                         TEPaste(myText[currentWindow]);
  603.                                                         AdjustScrollBar(currentWindow);
  604.                                                         CheckInsertion(currentWindow);
  605.                                                     END; { of else}
  606.                                             END
  607.                                         ELSE
  608.                                             sysbeep(5);
  609.                                     END; { of paste}
  610.                                 eClear : 
  611.                                     BEGIN
  612.                                         IF currentWindow <> 0 THEN
  613.                                             BEGIN
  614.                                                 CheckInsertion(currentWindow);
  615.                                                 TEDelete(myText[currentWindow]);
  616.                                                 AdjustScrollBar(currentWindow);
  617.                                                 CheckInsertion(currentWindow);
  618.                                             END
  619.                                         ELSE
  620.                                             sysbeep(5);
  621.                                     END;
  622.                                 eSelAll : 
  623.                                     BEGIN
  624.                                         IF currentWindow <> 0 THEN
  625.                                             BEGIN
  626.                                                 TESetSelect(0, MaxLines, myText[currentWindow]);
  627.                                                 TECopy(myText[currentWindow]);
  628.                                                 dummy := ZeroScrap;
  629.                                                 dummy := TEToScrap;
  630.                                             END
  631.                                         ELSE
  632.                                             sysbeep(5);
  633.                                     END;
  634.                                 eClipboard : 
  635.                                     BEGIN
  636.                                         currentWindow := 0;
  637.                                         SetPort(ClipBdWindow);
  638.                                         ShowWindow(ClipBdWindow);
  639.                                         SelectWindow(ClipBdWindow);
  640.                                         UpdateMenus;
  641.                                     END;
  642.                                 OTHERWISE {no menu items selected}
  643.                                     BEGIN
  644.                                     END;
  645.                             END; {of theItem}
  646.                         END; {of if then}
  647.                 END; {of EditMenu}
  648.             SearchMenu : 
  649.                 BEGIN
  650.                 END;
  651.             FormatMenu : 
  652.                 BEGIN
  653.                 END;
  654.             FontMenu : 
  655.                 BEGIN
  656.                     doFonts(theItem);
  657.                 END;
  658.             SizeMenu : 
  659.                 BEGIN
  660.                     doSize(theItem);
  661.                 END;
  662.             StyleMenu : 
  663.                 BEGIN
  664.                     doStyle(theItem);
  665.                 END;
  666.             ModeMenu : 
  667.                 BEGIN
  668.                     doMode(theItem);
  669.                 END;
  670.             TransferMenu : 
  671.                 BEGIN
  672.                 END;
  673.             OTHERWISE
  674.                 BEGIN
  675.                 END;
  676.         END; {of theMenu}
  677.         HiliteMenu(0);    {un-hilite selected menu}
  678.     END;
  679.  
  680.     PROCEDURE doContent; {(ConEvent : EventRecord}
  681.                                     {contentWindow : windowPtr);}
  682.         VAR
  683.             localPt, globalPt : Point;
  684.             part : integer;
  685.             control : ControlHandle;
  686.             i : integer;
  687.     BEGIN
  688.         IF contentWindow <> FrontWindow THEN
  689.             SelectWindow(contentWindow);
  690.         globalPt := ConEvent.where;
  691.         localPt := globalPt;        {global coord of mouse}
  692.         GlobalToLocal(localPt);     {local coord of mouse}
  693.         part := FindControl(localPt, contentWindow, control);
  694.  
  695.         IF contentWindow = ClipBdWindow THEN
  696.             BEGIN
  697.                 currentWindow := 0;
  698.                 SetPort(ClipBdWindow);
  699.                 UpdateMenus;
  700.             END
  701.         ELSE
  702.             BEGIN
  703.                 FOR i := 1 TO MaxWindows DO
  704.                     IF contentWindow = myWindows[i] THEN
  705.                         BEGIN
  706.                             currentWindow := i;
  707.                             SetPort(myWindows[currentWindow]);
  708.                             UpdateMenus;
  709.                         END;
  710.             END;
  711.         i := currentWindow;
  712.         IF currentWindow <> 0 THEN
  713.             BEGIN
  714.                 IF part <> 0 THEN
  715.                     doScrollers(i, control, part, localpt);
  716.                 IF part = 0 THEN
  717.                     BEGIN
  718.                         IF PtInRect(localPt, myText[i]^^.viewRect) THEN
  719.                             BEGIN
  720.                                 TEClick(localPt, BitAnd(ConEvent.modifiers, ShiftKey) = ShiftKey, myText[i])
  721.                             END;  {of ptInRect}
  722.                     END; { of part=0 }
  723.             END; {of currentWindow <>0}
  724.     END;  {of proc}
  725.  
  726.     PROCEDURE doDrag; {(GrabWindow : WindowPtr}
  727.                                 {GlobalMouse : point);}
  728.         VAR
  729.             i : integer;
  730.     BEGIN
  731.         IF GrabWindow <> FrontWindow THEN
  732.             BEGIN
  733.                 SelectWindow(GrabWindow);
  734.                 IF GrabWindow = ClipBdWindow THEN
  735.                     BEGIN
  736.                         currentWindow := 0;
  737.                         SetPort(ClipBdWindow);
  738.                         UpdateMenus;
  739.                     END
  740.                 ELSE
  741.                     FOR i := 1 TO MaxWindows DO
  742.                         IF GrabWindow = myWindows[i] THEN
  743.                             BEGIN
  744.                                 currentWindow := i;
  745.                                 SetPort(myWindows[i]);
  746.                                 UpdateMenus;
  747.                             END;
  748.             END;
  749.         DragWindow(GrabWindow, GlobalMouse, DragArea);
  750.     END;
  751.  
  752.     PROCEDURE doGrow; {(ResizeWindow : WindowPtr;}
  753.                                 {Globalmouse : point;}
  754.                                 {ZoomFlg:Boolean);}
  755.         VAR
  756.             newSize : LongInt;
  757.             hsize : integer;
  758.             vsize : integer;
  759.             oldPort : GrafPtr;
  760.             saveRect : rect;
  761.             textlines : integer;
  762.             i : integer;
  763.             windowLines : integer;
  764.             CharPos : integer;
  765.             ControlLine : integer;
  766.             tempLong : LongInt;
  767.     BEGIN
  768.         IF (ResizeWindow <> FrontWindow) THEN
  769.             SelectWindow(ResizeWindow)
  770.         ELSE
  771.             BEGIN
  772.                 IF (ZoomFlg) THEN
  773.                     BEGIN
  774.                         WITH ResizeWindow^.portRect DO
  775.                             BEGIN
  776.                                 tempLong := bottom - top;
  777.                                 newSize := BitShift(tempLong, 16);
  778.                                 newSize := newSize + (right - left);
  779.                             END;
  780.                     END
  781.                 ELSE
  782.                     newSize := GrowWindow(ResizeWindow, Globalmouse, GrowArea);
  783.                 IF newSize <> 0 THEN
  784.                     BEGIN  {grow the window}
  785.                         hsize := LoWord(newSize);
  786.                         vsize := HiWord(newSize);
  787.                         IF ResizeWindow = ClipBdWindow THEN
  788.                             SizeWindow(ResizeWindow, hsize, vsize, true);
  789.                         FOR i := 1 TO MaxWindows DO
  790.                             BEGIN
  791.                                 IF ResizeWindow = myWindows[i] THEN
  792.                                     BEGIN
  793.                                         WITH ResizeWindow^.portRect DO {Pre-Grow}
  794.                                             BEGIN
  795.                                                 SetRect(VCRect, right - (SBarWidth - 1), top - 1, right + 1, bottom - (SBarWidth - 2));
  796.                                                 SetRect(HCRect, left - 1, bottom - (SBarWidth - 1), right - (SBarWidth - 2), bottom + 1);
  797.                                                 SetRect(GrowRect, HCRect.right, HCRect.top, VCRect.right, HCRect.bottom);
  798.                                             END;  {of with }
  799.                                         SizeWindow(ResizeWindow, hsize, vsize, TRUE); {new portRect}
  800.                                         InvalRect(GrowRect); {Pesky grow icon!!}
  801.                                         EraseRect(GrowRect);  {looks better if done after sizewind}
  802.                                         WITH ResizeWindow^.portRect DO {Post Grow}
  803.                                             BEGIN
  804.                                                 SetRect(VCRect, right - (SBarWidth - 1), top - 1, right + 1, bottom - (SBarWidth - 2));
  805.                                                 SetRect(HCRect, left - 1, bottom - (SBarWidth - 1), right - (SBarWidth - 2), bottom + 1);
  806.                                                 SetRect(GrowRect, HCRect.right, HCRect.top, VCRect.right, HCRect.bottom);
  807.                                                 SetRect(ViewRect, left + 4, top + 4, right - (SBarWidth - 1), bottom - (SBarWidth - 1));
  808.                                             END;  {of with }
  809.                                         DestRect := ViewRect;
  810.  
  811.                                         InvalRect(GrowRect);  {needed for update on shrink}
  812.                                         HideControl(myVControls[i]);
  813.                                         HIdeControl(myHControls[i]);
  814.                                         MoveControl(myVControls[i], VCRect.left, VCRect.top);
  815.                                         MoveControl(myHControls[i], HCRect.left, HCRect.top);
  816.                                         SizeControl(myVControls[i], SBarWidth, VCRect.bottom - VCRect.top);
  817.                                         SizeControl(myHControls[i], HCRect.right - HCRect.left, SBarWidth);
  818.                                         ShowControl(myVControls[i]);
  819.                                         ShowControl(myHControls[i]);
  820.                                         Validrect(HCRect);
  821.                                         ValidRect(VCRect);
  822.  
  823.                     {Update TextEdit Display}
  824.                                         myText[i]^^.ViewRect := ViewRect;
  825.                                         myText[i]^^.DestRect := DestRect;
  826.                                         currentWindow := i;
  827.                                         BashText;
  828.  
  829.                                     END; {of if ResizeWindow}
  830.                             END;  {of i =1 to MaxWindows}
  831.                     END; {of else grow window stuff}
  832.             END; {of if then newsize}
  833.     END;  { of proc }
  834.  
  835. END. {of unit}